#pragma once
//#define SDLPP_USE_ALL
#include <sdl.hpp>

#include <vector>
#include <memory>
#include <functional>

class IDrawable {
  public:
    virtual const char* title() = 0;
    virtual void init() {};
    virtual void uninit() {};
    virtual void update(float elapsedTime) {};
    virtual void render() {};
    virtual void processInput(sdl::event::Event &evt) {};
};

namespace gl = sdl::gl;
extern sdl::Window::Wrapped window_;
extern gl::Context context_;
extern void addCreateDrawable(std::function<std::shared_ptr<IDrawable>()> fun);

#define DECLARE_DRAWABLE_BEGIN(classname,titlename) \
  namespace { \
    class classname : public IDrawable { \
      public: \
        virtual const char* title() override { return #titlename; }

#define DECLARE_DRAWABLE_END(classname) \
    }; \
    struct classname ## _struct { \
      classname ## _struct() { \
        addCreateDrawable([]() -> std::shared_ptr<IDrawable> { \
          return std::make_shared<classname>(); \
        }); \
      } \
    } __ ## classname; \
  }